<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // function add() {
      //   return function () {
      //     return function () {};
      //   };
      // }

      let num = 0;
      function add(x) {
        num += x;
        return add;
      }

      add.toString = function () {
        return num;
      };
      // Number(add)
      console.log(Number(add(1)(2)(3)(3)) - 3); //9
    </script>
  </body>
</html>
